{% extends "base/basehead.html" %}
{% block title %}
NiceNovel注册
{% endblock %}
{% block content %}
    <div class="modal" id="model" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="modeltext">
                <p></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Ok</button>
            </div>
        </div>
    </div>
</div>
    <div class="modal" id="model" tabindex="-1">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body" id="modeltext">
                <p></p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Ok</button>
            </div>
        </div>
    </div>
</div>
    <div class="container">
			<br><br><br><br><br><br><br><br>
			<div class="row">
				<div class="col-md-4">
				</div>
				<div class="col-md-4">
					<div class="row">

						<form action="register" method="post">
						  <div class="form-group">
						    <label for="exampleInputEmail1">邮箱</label>
						    <input type="email" name="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp">
						    <small id="emailHelp" class="form-text text-muted"></small>
						  </div>
						  <div class="form-group">
						    <label for="exampleInputPassword1">请输入密码</label>
						    <input type="password" name="password" class="form-control" id="exampleInputPassword1">
						  </div>
						  <div class="form-group">
						    <label for="exampleInputPassword1">请再次输入密码</label>
						    <input type="password" class="form-control" id="exampleInputPassword2">
						  </div>

						  	<div class="form-row">
						  	    <div class="col-md-6">
						  	      <input type="text" class="form-control" name="yzm" placeholder="验证码">
						  	    </div>
						  	    <div class="col-md-6">
						  	    	<button type="button" id="yzm" class="btn btn-info" >获取验证码</button>
						  	    </div>
						  	</div>
							<div class="row">
								<div class="col-md-4">
								</div>
								<div class="col-md-4">
									<br>
									<button type="submit" class="btn btn-primary">注册</button>
								</div>
								<div class="col-md-4">
								</div>
							</div>
						</form>
					</div>

				</div>
				<div class="col-md-4">
				</div>
			</div>
		</div>
{% endblock %}
{% block js %}
    <script type="text/javascript">
		$(document).ready(function(){
                $('#yzm').click(
			function(){
			    if ($("#exampleInputPassword1").val()==$("#exampleInputPassword2").val())
                {
                   $.ajax({
					type:"POST",
					url:"{% url 'getcode' %}",
					data:{"email":$("#exampleInputEmail1").val()},
					datatype:'json',
					success:function(data){
						$("#yzm").text(data.mes)
					},
                    error:function () {
                        $("#yzm").text("发送失败")
                    }
				});
                }else{
			        $("#modeltext").text('密码不一致');
                    $('#model').modal({
                        keyboard: false
                    });
                }

			});

		});
	</script>
{% endblock %}

